import request from '@/utils/request'

export function create(form) {
  const data = {
    name: form.name,
    gender: form.gender,
    career: form.career,
    email: form.email.value || form.email,
    account: form.account,
    password: form.password,
    role: form.role.name,
    phone: form.phone,
    invite: form.invite,
    note: form.note,
    state: 1
  }
  return request({
    url: '/user/create',
    method: 'post',
    data
  })
}

export function updateUser(data) {
  data.role = data.role.name
  return request({
    url: '/user',
    method: 'put',
    data
  })
}

export function getList(query) {
  return request({
    url: '/user',
    method: 'get',
    params: query
  })
}

export function setActive(data) {
  return request({
    url: '/setactive ',
    method: 'post',
    data: { uuid: data }
  })
}

export function getUserInfo(token) {
  return request({
    url: '/user/info',
    method: 'get',
    params: { token }
  })
}

export function delUser(id) {
  return request({
    url: '/user',
    method: 'delete',
    data: { id }
  })
}

